package com.example.juc_learn.service;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Service;

import java.util.concurrent.locks.ReentrantLock;

@Service
public class BillService {
    Logger logger = LoggerFactory.getLogger(BillService.class);
    ReentrantLock reentrantLock = new ReentrantLock();

    public void chageBill(String name,Integer money) throws InterruptedException {
        reentrantLock.lock();
        logger.info("-----------------"+name+"开始————————————");
        Thread.sleep(300);
        logger.info("-----------------"+name+"结束————————————");
        reentrantLock.unlock();
    }
}
